home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / amos / amoslist.lzh / AMOSLIST / 000343_amos-request@svcs1.digex.net_Tue Sep 26 14:59:17 1995.msg < prev    next >
Internet Message Format  |  1995-10-02  |  5KB

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224]) by mail1.access.digex.net (8.6.12/8.6.12) with ESMTP id OAA01761;  for <mcox@access.digex.net> ; Tue, 26 Sep 1995 14:59:16 -0400
  2. Received: (from daemon@localhost) by svcs1.digex.net (8.6.12/8.6.12) id MAA19055 for amos-out; Tue, 26 Sep 1995 12:11:30 -0400
  3. Received: from mail1.access.digex.net (mail1.access.digex.net [205.197.247.2]) by svcs1.digex.net (8.6.12/8.6.12) with ESMTP id MAA19050 for <amos-list@svcs1.digex.net>; Tue, 26 Sep 1995 12:11:27 -0400
  4. Received: from red.paston.co.uk (red.paston.co.uk [194.129.188.3]) by mail1.access.digex.net (8.6.12/8.6.12) with SMTP id MAA09594;  for <amos-list@access.digex.net> ; Tue, 26 Sep 1995 12:11:24 -0400
  5. Received: from localhost (bwyatt.paston.co.uk) by red.paston.co.uk (5.x/SMI-SVR4)
  6.     id AA05088; Tue, 26 Sep 1995 17:03:58 +0100
  7. Received: by paston.co.uk.uucp (V1.16/Amiga)
  8.     id AA001y4; Tue, 26 Sep 95 21:03:52 GMT
  9. Date: Tue, 26 Sep 95 21:03:52 GMT
  10. Message-Id: <9509262103.AA001y3@paston.co.uk.uucp>
  11. Lines: 102
  12. X-Mailer: ADMail 1.5 Copyright 1995 S.T.Brown
  13. From: bwyatt@paston.co.uk (Ben Wyatt)
  14. To: amos-list@access.digex.net
  15. Subject: Re: Help me!
  16. Status: RO
  17. X-Status: 
  18.  
  19. > BC> > M> I have to solve a problem in AMOS Pro programming: is there anyone who can
  20. > BC> > M> help me??
  21. > BC> > M> I explain the problem.
  22. > BC> > M> I must (or better, I want to) do a procedure to draw on a screen a part of
  23. > BC> > M>
  24. > BC> > M> a
  25. > BC> > M> circle. Is there any extension to do it??
  26. > BC> > M> Otherwise I have to use sin() and cos() function, but these are relly very
  27. > BC> > M> slow.
  28. > BC> > M> The procedure should be like:
  29. > BC> > M>
  30. > BC> > M> Procedure PART_OF_CIRCLE[R,A,B]
  31. > BC> > M>      where R is the radius, A the value of the angle in degree
  32. > BC> > M>      and B is how many degrees the line is long
  33. > BC> > M>      (sorry for my English, can you understand me? :-(( )
  34. > BC> > M> End Proc
  35. > BC> > M>
  36. > BC> > M> Unfortunately, becouse of all the structure of the program, the screen is
  37. > BC> > M> in
  38. > BC> > M> Hi resolution, but you have just to use R/2 in the sin() part.
  39. > BC> > M> But the biggest matter is that the 0 degree must be at 12 o'clock, 90
  40. > BC> > M> degrees at 3 o'clock and so on in clockwise (instead the trig functions
  41. > BC> > M> work
  42. > BC> > M> in the other direction.).
  43. > BC>
  44. > BC> I missed the original message due to problems with our mail-system last
  45. > BC> night, so I'll answer to this post. The answer is simple. Yes, there does
  46. > BC> exist such a procedure, I wrote it, it's in the Procedure Library (v3.0 I
  47. > BC> believe) which can be downloaded from Aminet or Andy's website. It's
  48. > BC> called SimpleArc and the good part is that with bigger circles (i.e. an
  49. > BC> arc with 360 degrees length) it is faster than the Amos 'Circle' command!
  50. >
  51. > I reckon mine would be faster with a big step (STP)
  52. >
  53. > BC> The trick I used to make it faster is to build the arc from lines instead
  54. > BC> of single dots. If anyone feels like making it even faster, be my guest.
  55. >
  56. > The only way of making it any faster is to use extension commands...
  57. >
  58.  
  59.     I'm sorry but that is inherently not true. I happen to be learning
  60. of many faster ways of creating circles or arcs without using sin's cos's,
  61. floating numbers and the like. There are many algorithms available that will
  62. generate circles faster than a line approximation(and much more circle like
  63. as well).
  64.  
  65. void circle(int x, int y,int r, Color c)
  66. {
  67.   int E,d_inc,r_inc,x1,x2,x3,x4,y1,y2,y3,y4;
  68.  
  69.   E=2*r-3;
  70.   d_inc=4*r-10;
  71.   r_inc=-6;
  72.   for(x1=x,y1=y+r,x2=x,y2=y-r,x3=x-r,y3=y,x4=x+r,y4=y;
  73.       (x4-x1)>0 ;x1++, x2--, y3++, y4--)
  74.     {
  75.       plot(x1,y1,c);
  76.       plot(x1,y2,c);
  77.       plot(x2,y2,c);
  78.       plot(x2,y1,c);
  79.       plot(x3,y3,c);
  80.       plot(x3,y4,c);
  81.       plot(x4,y4,c);
  82.       plot(x4,y3,c);
  83.  
  84.       if(E<0)
  85.     {
  86.       E+=d_inc;
  87.       d_inc-=8;
  88.       y1--;
  89.       y2++;
  90.       x3++;
  91.       x4--;
  92.     }
  93.       else
  94.     {
  95.       E+=r_inc;
  96.       d_inc-=4;
  97.     }
  98.       r_inc-=4;
  99.     }
  100. }
  101.  
  102. This is an example of real working circle routine that does not use a
  103. single cos, sin or float number. It can easily be modified to make ellipses
  104. and with a little thought, probably arcs as well. Basically the loop
  105. calculates the upper right hand 1/8th of a circle and the  other portions
  106. of the circle are mirrored. The 1/8th is created by maintaining an Error
  107. variable that determines when to draw diagonally other than the normal
  108. horizontal draw. My stopping condition is set up for circles and checks
  109. to see when the original and mirrored sections meet.
  110.  
  111. Check out some books on the subject and I'm sure you will see that there
  112. are many ways to draw arcs.
  113.  
  114.                 Robert Currie
  115.  
  116. -- 
  117. -----------------------------------------------------------
  118.             Robert Currie
  119.            currie@cpsc.ucalgary.ca
  120. -----------------------------------------------------------